<template>
  <view class="container">
    <view class="header" :style="[mpStyle]">
    <view class="left">
          <image class="avatar" src="@/static/images/tabbar_package.png" mode=""></image>
          <text class="nick">立即登录 </text>
        </view>
         <button class="right-btn">签到</button>
        </view>
    </view>
  </view>
</template>

<script>
import { mapState } from 'vuex';
export default {
  name: 'indexHeader',

  data() {
    return {};
  },
  computed: {
    ...mapState({
      menuButtonInfo: store => store.initApp.menuButtonInfo
    }),
   
    mpStyle() {
      // #ifdef MP-WEIXIN
      return {
        height: 'auto',
        marginTop: this.menuButtonInfo.top-25  + 'px', // 胶囊距离顶部的距离减去导航栏高度
        marginRight: this.menuButtonInfo.width  + 'px'
      };
      // #endif
      // #ifndef MP-WEIXIN
      return {};
      // #endif
    }
  },
  methods: {
    async checkIn() {
      // 签到
      try {
        // const res = await userSignIn();
        if (res) {
          uni.showToast({
            icon: 'none',
            title: '签到成功'
          });
        }
      } catch (e) {
        // TODO handle the exception
      }
    }
  }
};
</script>

<style lang="scss" scoped>
.container {
  padding-top: var(--status-bar-height);
  /* #ifdef H5 */
  padding-top:25rpx;
  /* #endif */
}
.header {
  height: 88rpx;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 28rpx;

  .left {
    display: flex;
    align-items: center;
  }

  .avatar {
    width: 60rpx;
    height: 60rpx;
    border-radius: 50%;
    background-color: $uni-text-color-primary;
  }

  .nick {
    font-size: 32rpx; 
    font-weight: 600;
    margin-left: 12rpx;
  }

  .right-btn {
    width: 100rpx;
    height: 56rpx;
    line-height: 56rpx;
    font-size: 24rpx;
    color: $uni-text-color-primary;
    background-color: #fff;
    margin: 0;
    padding: 0;
  }
}
</style>
